package com.song.composejoke.ui

import androidx.compose.foundation.layout.Column
import androidx.compose.material.AlertDialog
import androidx.compose.material.MaterialTheme.shapes
import androidx.compose.material.Text
import androidx.compose.material.TextButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import com.song.composejoke.R

@Composable
fun ProgressDialog(
    title: String,
    message: String,
    ok: () -> Unit,
    cancel: () -> Unit
) {
    AlertDialog(
        onDismissRequest = { },
        title = {
            Text(
                text = title,
            )
        },
        text = {
            Text(
                text = message,
            )
        },
        confirmButton = {
            TextButton(onClick = ok) {
                Text(
                    text = stringResource(id = R.string.ok),
                    color = Color.White
                )
            }
        },
        dismissButton = {
            TextButton(onClick = cancel) {
                Text(
                    text = stringResource(id = R.string.ok),
                    color = Color.White
                )
            }
        },
        shape = shapes.large,
    )
}

@Preview
@Composable
fun DefaultPreview() {
    Column() {
        ProgressDialog(title = "标题", message = "内容", ok = {}, cancel = {})
        Text(text = "1111")
    }
}
